import type { TFunction } from 'i18next';
import { getMetroStationPage } from '@/servers/metro/station';
import { Tag } from 'antd';

// 新增数据
export const createList = (t: TFunction, onPressEnter: () => void): BaseFormList[] => [
  {
    label: t('metro.cityStationButton'),
    name: 'stationCode',
    rules: FORM_REQUIRED,
    component: 'ApiPageSelect',
    componentProps: {
      autoFocus: true,
      api: getMetroStationPage as ApiFn,
      apiResultKey: 'records',
      queryKey: 'stationName',
      fieldNames: { label: 'stationName', value: 'id' },
      filterOption: false,
      optionRender: (v) => (
        <>
          <Tag>{v.data.cityName}</Tag>
          {v.data.stationName}
          {v.data.stationEn && `(${v.data.stationEn})`}
        </>
      ),
      params: {
        page: 1,
        pageSize: 10,
      },
    },
  },
  {
    label: t('metro.sort'),
    name: 'sort',
    rules: FORM_REQUIRED,
    component: 'InputNumber',
    componentProps: {
      onPressEnter,
    },
  },
];
